/***************************************************************************
 *   Copyright (C) 2005 by shao						   *
 *   swjbook@gmail.com							   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#include "cyclonePrefer.h"
#include "ConfFile.h"
#include <string>
using std::string;
CyclonePrefer::CyclonePrefer()
{
	reset_settings();
//	read_from_file();
}
CyclonePrefer::~CyclonePrefer()
{
}
void CyclonePrefer::reset_settings()
{
	if_sound=true;
	show_main=true;
	direct_login=false;
	popup_msg=true;
	save_log=true;
	string sound_file="not defined yet";
}
bool CyclonePrefer::get_if_sound()
{
	return if_sound;
}
void CyclonePrefer::set_if_sound(bool s)
{
	if_sound=s;
}
bool CyclonePrefer::get_show_main()
{
	return show_main;
}
void CyclonePrefer::set_show_main(bool s)
{
	show_main=s;
}
bool CyclonePrefer::get_direct_login()
{
	return direct_login;
}
void CyclonePrefer::set_direct_login(bool s)
{
	direct_login=s;
}
bool CyclonePrefer::get_popup_msg()
{
	return popup_msg;
}
void CyclonePrefer::set_popup_msg(bool s)
{
	popup_msg=s;
}
bool CyclonePrefer::get_save_log()
{
	return save_log;
}
void CyclonePrefer::set_save_log(bool s)
{
	save_log=s;
}
bool CyclonePrefer::read_from_file(const string & filename)
{
	string name;
	cf=new ConfFile(filename.c_str(),"r");
	cf->read_bool(name,if_sound);
	cf->read_bool(name,show_main);
	cf->read_bool(name,direct_login);
	cf->read_bool(name,popup_msg);
	cf->read_bool(name,save_log);
	cf->read_string(name,sound_file);
	cf->close();
	delete cf;
	cf=NULL;
	return false;
	
}
bool CyclonePrefer::write_to_file(const string & filename)
{
	string name;
	cf=new ConfFile(filename.c_str(),"w");
	cf->write_bool("IFSOUND",if_sound);
	cf->write_bool("SHOWMAIN",show_main);
	cf->write_bool("DIRECTLOGIN",direct_login);
	cf->write_bool("POPUPMSG",popup_msg);
	cf->write_bool("SAVELOG",save_log);
	cf->write_string("SOUNDFILE",sound_file);
	cf->close();
	delete cf;
	cf=NULL;
	return false;
}
